package com.cloud.pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;

public class PageManager {

    private WebDriver driver;
    public MainPage mainPage;
    public TermsPage termsPage;
    public LoginPage loginPage;
    public PrivacyPage privacyPage;
    public InternalPage internalPage;
    public RegisterPage registerPage;
    public MyProfilePage myProfilePage;
    public UserProfilePage userProfilePage;
    public ForgotPassPage forgotPassPage;



    public PageManager(WebDriver driver) {

        this.driver = driver;
        mainPage = initElements(new MainPage(this));
        loginPage = initElements(new LoginPage(this));
        termsPage = initElements(new TermsPage(this));
        privacyPage = initElements(new PrivacyPage(this));
        registerPage = initElements(new RegisterPage(this));
        internalPage = initElements(new InternalPage(this));
        myProfilePage = initElements(new MyProfilePage(this));
        forgotPassPage = initElements(new ForgotPassPage(this));
        userProfilePage = initElements(new UserProfilePage(this));

    }

    private <T extends Page> T initElements(T page) {
        PageFactory.initElements(new DisplayedElementLocatorFactory(driver, 10), page);
        //PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), page);
        //PageFactory.initElements(driver, page);
        return page;
    }

    public WebDriver getWebDriver() {
        return driver;
    }

}
